"""
1).连接到数据库（host:localhost user:root password:root database:books）
2).获取数据库服务器版本信息

"""

# 导包
import pymysql

# 创建连接
conn = pymysql.connect(host="localhost",
                       port=3306,
                       user="root",
                       password="root",
                       database="books")

# 获取游标
cursor = conn.cursor()
sql = "select * from t_book"
# 执行sql
data = cursor.execute(sql)
result = cursor.fetchall()
print(result)


# 关闭游标
cursor.close()

# 关闭连接
conn.close()

